package com.shundr.auth.frame.util;

import java.io.File;

import android.content.Context;

import com.shundr.auth.frame.constant.LConstants;
import com.shundr.auth.frame.constant.LContext;
import com.shundr.auth.frame.db.LDaoManager;

/**
 * 
 * LLoader 应用开启时初始化应用的loader
 * 
 * @author larry 2015-4-10 下午2:33:48
 * @version 1.0.0
 *
 */
public class LLoader {

	public static boolean isInit = false;

	public static void initApp(Context context) {
		if (isInit) {
			return;
		}
		
		isInit = true;
		creatBaseDirectory();
		LContext.init(context);
		LDaoManager.init(context);
		LLogger.e("数据初始化完成");
	}
	
	protected static void creatBaseDirectory(){
		if(!new File(LConstants.CRASH_PATH).exists()){
			new File(LConstants.CRASH_PATH).mkdirs();
		}
		if(!new File(LConstants.SOUND_PATH).exists()){
			new File(LConstants.SOUND_PATH).mkdirs();
		}
		if(!new File(LConstants.TEMP_PATH).exists()){
			new File(LConstants.TEMP_PATH).mkdirs();
		}
		if(!new File(LConstants.DOWNLOAD_APP_PATH).exists()){
			new File(LConstants.DOWNLOAD_APP_PATH).mkdirs();
		}
	}

}
